﻿#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
using namespace std;

class Building
{
	//3.让全局的好基友函数goodGay()，变成我的好朋友，友元函数；目的就是可以访问类中的私有成员属性；
	friend void goodGay(Building* building);

public:
	Building()
	{
		this->m_SittingRoom = "客厅";
		this->m_BedRoom = "卧室";
	}

	//1.客厅，卧室；
public:
	string m_SittingRoom;
private:
	string m_BedRoom;
};
//2.全局函数，好基友；
void goodGay(Building* building)
{
	cout << "好基友正在访问-->" << building->m_SittingRoom << endl;//客厅
	cout << "好基友正在访问-->" << building->m_BedRoom << endl;//卧室
}
void testFriendFunc()
{
	Building* building = new Building;
	goodGay(building);
}

//main273：全局函数做友元函数
int main273()
{
	testFriendFunc();

	system("pause");
	return EXIT_SUCCESS;
}